有時候反向代理的域名
會需要新增
透過 api server接收後
執行sh 動態來為 nginx server_name 新增
api server
npm install child_process
const { exec } = require('child_process');
exec('sh add_domX.sh ' + _domain , (err, stdout, stderr) => {});
add_domX.sh
cat << EOF > /etc/nginx/conf.d/$1.conf
server {
listen 80;
server_name $1;
location / {
proxy_pass http://yourip;
}
}
EOF
systemctl restart nginx